@extends('layout.master')
@section('title', '后台管理系统')
@section('content')
<!-- 详情 签收1 签收2 任务结束1 任务结束2 任务核查 任务转派 分配任务 审批轨迹 -->
<div id="w" class="easyui-window win" data-options="iconCls:'icon-save',minimizable:false,closed:true"
     style="overflow-y: hidden;overflow-x: auto">
    <iframe src="" frameborder="0" width="100%" height="100%"></iframe>
</div>
<!-- ******************************************************************* -->
<div id="tb" class="easyui-panel" data-option="fit:true">
<table style="width:100%">
    <tr>
        <td style="width:8%">事件标题：</td>
        <td style="width:17%"><input class="easyui-textbox sjbt" style="width:100%;height:32px" prompt="请输入标题"></td>
        <td style="width:8%">事件状态：</td>
        <td style="width:17%">
            <select class="easyui-combobox sjzt" name="state" style="width:100%;">
                <option value="">请选择</option>
                <option value="1">待签收</option>
                <option value="2">已签收</option>
                <!--<option value="3">平台自行处理</option>-->
                <option value="5">转办</option>
                <!--<option value="6">部门签收</option>-->
                <!--<option value="7">部门处理中</option>-->
                <option value="8">部门完结</option>
                <option value="4">核查通知</option>
                <option value="10">已办结</option>
            </select>
        </td>
        <td style="width:8%">处理部门：</td>
        <td style="width:17%">
            <select class="easyui-combobox clbm" name="state" style="width:100%;">
                <option value="">请选择</option>
                <option value="17">联峰物业</option>
                <option value="35">永合社区</option>
                <option value="16">惠邻社工</option>
                <option value="31">民生事务办</option>
                <option value="32">综合管理办</option>
                <option value="33">经济合作社</option>
                <option value="26">颐和公寓</option>
                <option value="36">景区办</option>

                <option value="1771">职工服务中心</option>
            </select>
        </td>
        <td style="width:8%">上报人：</td>
        <td style="width:17%"><input class="easyui-textbox sbr" style="width:100%;height:32px" prompt="请输入上报人"></td>
    </tr>
    <tr>
        <td style="width:8%">处置方案：</td>
        <td style="width:17%">
        <select class="easyui-combobox czfa" name="state" style="width:100%;">
            <option value="">请选择</option>
            <option value="1">自行处置归档</option>
            <option value="2">上报平台处理</option>
        </select>
        </td>
        <td style="width:8%">事件分类：</td>
        <td style="width:17%">
        <select class="easyui-combobox sjfl" name="state" style="width:100%;">
            <option value="">请选择</option>
            <foreach name="sjfl" item="vo"><option value="{$vo.id}">{$vo.name}</option></foreach>

        </select>
        </td>
        <td style="width:8%">事件来源：</td>
        <td style="width:17%">
        <select class="easyui-combobox sjly" name="state" style="width:100%;">
            <option value="">全部</option>
            <option value="2">议事厅</option>
            <option value="3">400热线</option>
            <option value="1">事件上报</option>
            <option value="4">红星闪耀</option>
        </select>
        </td>
        <td style="width:8%">是否有效：</td>
        <td style="width:17%">
        <select class="easyui-combobox sfyx" name="state" style="width:100%;">
            <option value="">请选择</option>
            <option value="1">有效</option>
            <option value="2">无效</option>
        </select>
        </td>
    </tr>
    <tr>
        <td style="width:8%">发布时间：</td>
        <td style="width:17%">
            <input class="easyui-datebox stime" name="stime"
                   style="width:48%;height:32px" prompt="请选择开始时间"
                   data-options="formatter:$.formatDate,parser:$.myParse">
            <input class="easyui-datebox etime" name="etime"
                   style="width:48%;height:32px;float: left;" prompt="请选择结束时间"
                   data-options="formatter:$.formatDate,parser:$.myParse">
        </td>
    </tr>
</table>
<div class="toolbar">
    <a href="#" class="easyui-linkbutton ssbtn"     event="ss"     iconCls="icon-search">搜索</a>
    <a href="#" class="easyui-linkbutton qkbtn"     event="qk"     iconCls="icon-more">清空</a>
    <!--<a href="#" class="easyui-linkbutton xqbtn"     event="xq"     iconCls="icon-more">详情</a>-->
    <a href="#" class="easyui-linkbutton"  onclick="$.sjtj1()" iconCls="icon-man">事件统计(人/月)</a>
    <a href="#" class="easyui-linkbutton"  onclick="$.sjtj2()" iconCls="icon-man">事件统计(类型/月)</a>
    <a href="#" class="easyui-linkbutton dcbtn"     event="dc"     iconCls="icon-print">导出</a>
    <if condition="$gird_del eq true">
        <a href="#" class="easyui-linkbutton scbtn"     event="sc"     iconCls="icon-cut">作废</a>
    </if>
    <!-- <a href="#" class="easyui-linkbutton hfbtn"     event="hf"     iconCls="icon-cut">恢复</a> -->
</div>
</div>
<!-- *************************************************************** -->
<!-- 对话框开始 -->
<!-- 对话框结束 -->
<body class="easyui-layout">
<table style="width:700px;height:250px;padding:200px;" id="dg"></table>
<script>
$('#dg').datagrid({
	fit:true,
	url: 'http://zhyl.yong-gang.com/zhyl/index.php/Admin/Gird/gird_eventlist_interface',
	method: 'post',
	nowrap:false,
	pagination:true,
	pageSize:50,
	singleSelect:true,
    nowrap: true,
	loadMsg : '正在加载数据，请稍候...',
    emptyMsg: '<span>没有相关记录</span>',
    toolbar:"#tb",
    onDblClickCell: function (index, field, value) {
    var row = $('#dg').datagrid('getSelected');
    addTab('事件详情',`http://zhyl.yong-gang.com/zhyl/index.php/Admin/Gird/gird_detail/id/${row.id}/type/${row.type}`);
},
    onLoadSuccess:function(data){
    if(!data.ldqs)   $('.ldqsbtn1').hide();
    if(!data.bmqs)   $('.bmqsbtn2').hide();
    if(!data.ldrwjs) $('.ldrwjsbtn').hide();
    if(!data.bmrwjs) $('.bmrwjsbtn').hide();
    if(!data.rwhc)   $('.rwhcbtn').hide();
    if(!data.zpbm)   $('.rwzpbtn').hide();
    if(!data.rwfp)   $('.rwfpbtn').hide();
},
    // 0、草稿(网格员可见) 1、待签收 2、已签收 3、平台自行处理 4、核查通知 10、任务结束
    //  * 5、转派部门  6、部门签收 7、部门处理中   8、部门完结   4、核查通知    10、任务结束
	columns: [[
			{ field: 'ck', checkbox:true},
			{ field: 'xh', width:50,align:'center',title:'序号'},

            {"field" : "cz","title"   : "操作","width" : 150,"align" : 'center',formatter:function(value,row,index){
                if(row.type==2){
                    var bn1 = row.bbsstatus==1?'撤销':'审核',
                    bn2 = row.is_cn==1?'已采纳':'未采纳',
                    bn3 = row.is_finish==1?'已解决':'未解决',
                    // str="<input type='button' event='verify' class='vbtn' value="+bn1+"><input type='button' event='cna' class='vbtn' value="+bn2+"><input type='button' event='finish' class='vbtn' value="+bn3+"><input type='button' class='vbtn' event='hf' value='回复'>";
                    str="<input type='button' event='verify' class='vbtn' value="+bn1+"><input type='button' event='cna' class='vbtn' value="+bn2+"><input type='button' event='finish' class='vbtn' value="+bn3+">";

                    //str="<input type='button' event='verify' class='vbtn' value="+bn1+"><input type='button' event='cna' class='vbtn' value="+bn2+"><input type='button' event='finish' class='vbtn' value="+bn3+"><input type='button' event='sc' class='vbtn'  value='删除'><input type='button' class='vbtn' event='hf' value='回复'>";
                    return str;
                }
            }},
            {"field" : "sjbt","title" : "事件标题","width" : 200,"align" : 'center'},
            {"field" : "sfyxstr","title" : "是否有效","width" : 100,"align" : 'center'},
            {"field" : "sbsj","title" : "上报时间","width" : 120,"align" : 'center',"sortable":true},
            // {"field" : "sjms","title" : "事件描述","width" : 200,"align" : 'center'},
			{"field" : "sjzt","title" : "事件状态","width" : 100,"sortable":true,"align" : 'center',formatter:function(value,row,index){
                var str="";
                switch(row.sjzt){
                    case "1":
                        str="待签收";
                        break;
                    case "2":
                        str="已签收";
                        break;
                    case "3":
                        str="平台自行处理";
                        break;
                    case "4":
                        str="核查通知";
                        break;
                    case "5":
                        str="转办";
                        break;
                    case "7":
                        str="部门处理中";
                        break;
                    case "8":
                        str="部门完结";
                        break;
                    case "10":
                        str="已办结";
                        break;
                }
                return str;
            }},
            {"field" : "type","title" : "事件来源","width" : 120,"align" : 'center',formatter:function(value,row,index){
                var str="";
                switch(row.type){
                    case "1":
                        str="事件上报";
                        break;
                    case "2":
                        str="议事厅";
                        break;
                    case "3":
                        str="400热线";
                        break;
                }
                return str;
            }},
            {"field" : "bbsstatus","title" : "审核状态","width" : 100,"align" : 'center',formatter:function(value,row,index){
                var str="";
                str = row.bbsstatus==1?'已审核':'未审核';
                if(row.bbsstatus==""){
                    str="";
                }
                return str;
            }},
            {"field" : "is_cn","title" : "采纳状态","width" : 100,"align" : 'center',formatter:function(value,row,index){
                var str="";
                str = row.is_cn==1?'已采纳':'未采纳';
                return str;
            }},
            {"field" : "clr","title" : "处理人","width" : 100,"align" : 'center'},
			{"field" : "czfa","title" : "处置方案","width" : 100,"align" : 'center'},
			{"field" : "yzcd","title" : "严重程度","width" : 100,"align" : 'center',styler:function(value,row,index){
                var str=""
                if(row.yzcd=='轻微'){
                    str= 'background-color:#00FF7F;color:red;';
                }else if(row.yzcd=='一般'){
                    str= 'background-color:#FFFF00;color:red;';
                }else if(row.yzcd=='严重'){
                    str= 'background-color:	#FF0000;color:white;';
                }
                return str;
            }},
			{"field" : "sjfl","title" : "事件分类","width" : 100,"align" : 'center'},
            {"field" : "sbr","title" : "上报人","width" : 100,"align" : 'center'},
            {"field" : "sjdw","title" : "事件定位","width" : 150,"align" : 'center'},
            {"field" : "zfr","title" :  "作废人","width" : 100,"align" : 'center'},
            {"field" : "zfsj","title" : "作废时间","width" : 120,"align" : 'center'},
            {"field" : "zfyy","title" : "作废原因","width" : 150,"align" : 'center'}
	    ]
    ]
});
$(document).on("click",'.vbtn',function(){
    var ename = $(this).attr('event'), row = $('#dg').datagrid('getSelected');
    switch(ename){
        case 'verify':
            var str = row.bbsstatus==1?'确认撤销?':'确认审核?'
            $.messager.confirm('提示信息', str, r => {
            if (r)
                postdata('http://zhyl.yong-gang.com/zhyl/index.php/Admin/Village/gird_verify',row.id,'操作成功');
        });

        break;
        case 'cna':
            postdata('http://zhyl.yong-gang.com/zhyl/index.php/Admin/Village/gird_ca',row.id,'操作成功');
            break;
        case 'finish':
            postdata('http://zhyl.yong-gang.com/zhyl/index.php/Admin/Village/gird_finish',row.id,'操作成功');
            break;
        case 'sc':
            postdata('http://zhyl.yong-gang.com/zhyl/index.php/Admin/Village/del_bbslist',row.id,'操作成功');
            break;
        case 'hf':
            addTab('帖子回复',`http://zhyl.yong-gang.com/zhyl/index.php/Admin/Village/answer_to?id=${row.id} & bbs_user_id=${row.bbs_user_id}`);
            break;
    }
})
$('.easyui-linkbutton').on("click",function(){
    var eventname = $(this).attr('event'),row = $('#dg').datagrid('getSelected');
    switch(eventname){
        case 'sc':
            if(!row){
                info_dialog('请至少选择一条数据');
                return false;
            }
            $.messager.confirm('提示信息', '确认作废吗?', r => {
            if(r){
                $.messager.prompt('提示信息', '请输入作废原因', rr => {
                    if(rr){
                        $.post(header+'Gird/delete_list',{id:row.id,type:row.type,zfyy:rr},res=>{
                            info_dialog(res.msg);
                            $.reloadTable();
                        },'json')
                    }
                            else if(rr === ""){
                                info_dialog("作废原因不能为空");
                    }
                    else{
                                    //“取消”事件
                    }
                })
            }
        })


        break;
        case 'hf':
            if(!row){
                info_dialog('请至少选择一条数据');
                return false;
            }
            $.messager.confirm('提示信息', '是否确认恢复?', r => {
            if (r) {
                $.post(header+'Gird/hf_list',{id:row.id,type:row.type},res=>{
                    info_dialog(res.msg);
                    $.reloadTable();
                },'json')
            }

        })

        break;
        case 'ss':
            $('#dg').datagrid('load',{
            'sjbt': $('.sjbt').val(),
            'sjzt': $('.sjzt').val(),
            'yzcd': $('.yzcd').val(),
            'jjcd': $('.jjcd').val(),
            'czfa': $('.czfa').val(),
            'sjfl': $('.sjfl').val(),
            'sjly': $('.sjly').val(),
            'sbr' : $('.sbr').val(),
            'sfyx': $('.sfyx').val(),
            'clbm': $('.clbm').val(),
            'stime': $('.stime').val(),
            'etime': $('.etime').val()
        });
        break;
        case 'qk':
        $('table').form('clear');
        break;
        case 'xq':
        var aaa=`http://zhyl.yong-gang.com/zhyl/index.php/Admin/Gird/gird_detail/id/${row.id}/type/${row.type}`;
        !row?info_dialog('请至少选择一条'):addTab('事件详情',`http://zhyl.yong-gang.com/zhyl/index.php/Admin/Gird/gird_detail/id/${row.id}/type/${row.type}`);
        break;

		case 'dc':
              if(!row){
                  info_dialog('请至少选择一条');
                  return false;
              }
            location.href=`http://zhyl.yong-gang.com/zhyl/index.php/Admin/Gird/print_event/id/${row.id}/type/${row.type}`;

        case 'ldqs':
  //       if(!row){
  //           info_dialog('请至少选择一条');
  //           return false;
  //       }
  //       if(row.sjzt!=1){
  //           info_dialog('当前不能进行该操作');
  //           return false;
  //       }
  //       $.messager.confirm('提示信息', '确认签收吗?', function(r){
  //           if (r){
  //               $.post("http://zhyl.yong-gang.com/zhyl/index.php/Admin/Gird/eventlist_ldqs",{
  //                   "id"   : row.id,
  //                   "type" : row.type
  //               },function(res){
  //                   $('#dg').datagrid("load");
  //               });
  //           }
		// });
        break;
        case 'ldrwjs':
        if(!row){
            info_dialog('请至少选择一条');
            return false;
        }
        if(row.sjzt==1){
            info_dialog('请先签收后再进行操作');
            return false;
        }
        //2 4 可以操作 1,3,5,7,8,10
        if(row.sjzt!=2 && row.sjzt!=4){
            info_dialog('当前不能进行该操作');
            return false;
        }
        $.messager.prompt('意见填写', '请输入意见内容', function(r){
            if(r){
                $.post('http://zhyl.yong-gang.com/zhyl/index.php/Admin/Gird/ldrwjs',{
                "id"   : row.id,
                "type" : row.type,
                "comment" : r
                },function(res){
                    info_dialog('操作成功');
                    $('#dg').datagrid("load");
                })
            }
        });
        break;
        case 'rwhc':
        if(row.sjzt==4){
            info_dialog('该任务核查通知已发出');
            return false;
        }
        if(row.sjzt!=8){
            info_dialog('请先结束任务在请求任务核查');
            return false;
        }
        $.messager.prompt('意见填写', '请输入意见内容', function(r){
            if(r){
                $.post('http://zhyl.yong-gang.com/zhyl/index.php/Admin/Gird/eventlist_rwhc',{
                "id"   : row.id,
                "type" : row.type,
                "comment" : r
                },function(res){
                    info_dialog('操作成功');
                    $('#dg').datagrid("load");
                })
            }
        });
        break;
        case 'rwzp':
        if(row.sjzt==1){
            info_dialog('请先签收后再进行操作');
            return false;
        }
        if(row.sjzt==10){
            info_dialog('该任务已完结');
            return false;
        }
        if(row.sjzt==4){
            info_dialog('当前不能进行该操作');
            return false;
        }
        !row?info_dialog('请至少选择一条'):addTab('任务转派','http://zhyl.yong-gang.com/zhyl/index.php/Admin/Gird/gird_rwzp/id/'+row.id+'/type/'+row.type);
        break;
        //部门任务结束
        case 'bmrwjs':
        if(!row){
            info_dialog('请至少选择一条');
            return false;
        }
        if(row.sjzt==4){
            info_dialog('当前不能进行该操作');
            return false;
        }
        $.messager.prompt('意见填写', '请输入意见内容', function(r){
            if(r){
                $.post('http://zhyl.yong-gang.com/zhyl/index.php/Admin/Gird/bmrwjs',{
                "id"   : row.id,
                "type" : row.type,
                "comment" : r
                },function(res){
                    info_dialog('操作成功');
                    $('#dg').datagrid("load");
                })
            }
        });
        break;
        case 'rwfp':
        if(!row){
            info_dialog('请至少选择一条');
            return false;
        }
        if(row.sjzt==4){
            info_dialog('当前不能进行该操作');
            return false;
        }
        addTab('任务分配','http://zhyl.yong-gang.com/zhyl/index.php/Admin/Gird/gird_rwfp/id/'+row.id+'/type/'+row.type)
        break;
        case 'spgj':
        if(!row){
            info_dialog('请至少选择一条');
            return false;
        }
        addTab('审批轨迹','http://zhyl.yong-gang.com/zhyl/index.php/Admin/Gird/gird_spgj/id/'+row.id+'/type/'+row.type);
        break;
        // case "sc":
        // $.post('http://zhyl.yong-gang.com/zhyl/index.php/Admin/Village/del_bbslist',{
        //     "id":row.id
        // },function(res){
        //     info_dialog('操作成功');
        //     $('#dg').datagrid("load");
        // })
        // break;
    }

    return false;
})
@endsection
